#ifndef _PHONEGAPFORM_H_
#define _PHONEGAPFORM_H_

#include <FBase.h>
#include <FUi.h>
#include <FWeb.h>
#include <FSystem.h>

#include "api/PluginManager.h"

class PhoneGapForm :
	public Osp::Ui::Controls::Form,
	public Osp::Web::Controls::ILoadingListener
{

// Construction
public:
	PhoneGapForm(void);
	~PhoneGapForm(void);
	bool Initialize(void);

// Implementation
protected:
	Osp::Web::Controls::Web*							__pWeb;
	PluginManager *										__pPluginManager;

	bool												__isNativeReady;
	Osp::Base::Collection::QueueT<Osp::Base::String>	__requests;

public:

	void LoadUrl(Osp::Base::String url);
	Osp::Base::String evaluateJavascript(Osp::Base::String javascript);
	/* ready pluginManager */
	result nativeReady();
	/* execute command */
	result exec(Osp::Base::String service,Osp::Base::String action,Osp::Base::String callbackId,Osp::Base::String jsonArgs,bool isAsync);

	virtual result OnInitializing(void);
	virtual result OnTerminating(void);

	virtual bool  OnLoadingRequested (const Osp::Base::String &url, Osp::Web::Controls::WebNavigationType type);
	virtual void  OnLoadingCompleted (void);
	void  OnEstimatedProgress (int progress){}
	void  OnHttpAuthenticationCanceled (void){}
	bool  OnHttpAuthenticationRequestedN (const Osp::Base::String &host, const Osp::Base::String &realm, const Osp::Web::Controls::AuthenticationChallenge &authentication){return true;}
	void  OnLoadingCanceled (void){}
	void  OnLoadingErrorOccurred (Osp::Web::Controls::LoadingErrorType error, const Osp::Base::String &reason){}
	void  OnLoadingStarted (void){}
	void  OnPageTitleReceived (const Osp::Base::String &title){}
	Osp::Web::Controls::DecisionPolicy  OnWebDataReceived (const Osp::Base::String &mime, const Osp::Net::Http::HttpHeader &httpHeader){return Osp::Web::Controls::WEB_DECISION_CONTINUE;}
};

#endif	//_PHONEGAPFORM_H_
